import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
// 定义 interfacePar 的结构

type Result = {
  code: number;
  data?: Record<string, any>[];
  msg: string;
};
type add = {
  code: number;
  status: number;
  error: string;
};
// type add = {
//   code: number;
//   error: string;
// };
export type getHomeResult = {
  code: any;
  message: string;
  data?: {
    product: any;
    deviceInfo: any;
    interfaces: any;
  };
};
// 查询  进来的时候  读取当前的服务器信息
export const getServerData = (data?: object) => {
  return http.request<getHomeResult>("post", baseUrlApi("service/get"), {
    data
  });
};

// 点击添加 服务器的按钮
export const addServerData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/create"), {
    data
  });
};
// 点击添加 服务器的按钮
export const updateServerData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/update"), {
    data
  });
};
// 点击删除 服务器的按钮
export const deleteServerData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/delete"), {
    data
  });
};

// 新增  服务器下的 组
export const addGroupData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/groupCreate"), {
    data
  });
};

// 修改  服务器下的 组
export const updateGroupData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/updateGroup"), {
    data
  });
};

// 查询  进来的时候  读取边缘采集的数据
export const getAcquisitionData = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("edgeAcquisition/get"), {
    data
  });
};

// 给组下面  新增变量
export const addVariableData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/addVar"), {
    data
  });
};
// 把整个设备的变量  添加为组
export const addVariableDataByDevice = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/addDevVar"), {
    data
  });
};

// 把整个设备的变量  添加为组
export const addVariableDataByAll = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/addAllVar"), {
    data
  });
};

//    修改组下面变量
export const updateVariableData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/updateVar"), {
    data
  });
};

//   删除组下面 变量
export const deleteVariableData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/deleteVar"), {
    data
  });
};

// 点击删除 分组的按钮
export const deleteGroupData = (data?: object) => {
  return http.request<add>("post", baseUrlApi("service/deleteGroup"), {
    data
  });
};
